Merged
Conversation
sumitmsft
reviewed
Aug 24, 2025
sumitmsft
reviewed
Aug 24, 2025
sumitmsft
reviewed
Aug 25, 2025
sumitmsft
reviewed
Aug 25, 2025
sumitmsft
approved these changes
Sep 15, 2025
sumitmsft
previously approved these changes
Sep 16, 2025
Contributor
There was a problem hiding this comment.
Pull Request Overview
This pull request adds a flexible output converter system to the mssql-python database connection, allowing custom Python functions to be registered for converting SQL data types when fetching results. The implementation includes comprehensive thread-safe methods for managing converters and robust integration with the row handling logic.
- Adds connection-level output converter management methods (add, get, remove, clear) with thread safety
- Updates Row class to automatically apply registered output converters during data fetching with error handling
- Includes extensive testing for converter registration, retrieval, integration, and edge cases
Reviewed Changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| mssql_python/connection.py | Adds output converter management methods and convenience execute() method with thread-safe implementation |
| mssql_python/row.py | Updates Row class to apply output converters automatically with fallback logic and error handling |
| tests/test_003_connection.py | Adds comprehensive tests for output converter functionality including helper functions and edge cases |
| tests/test_004_cursor.py | Reorganizes test functions by moving them to different locations within the file |
| tests/test_001_globals.py | Adds duplicate test for decimal separator functionality |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
gargsaumya
approved these changes
Sep 18, 2025
sumitmsft
approved these changes
Sep 18, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Work Item / Issue Reference
Summary
This pull request adds a flexible output converter system to the database connection, allowing custom Python functions to be registered for converting SQL data types when fetching results. It introduces new methods for managing these converters and updates the row handling logic to apply them automatically. Comprehensive tests are added to verify correct registration, retrieval, removal, and integration of output converters, including edge cases and chaining behavior.
Core output converter system:
Connection(add_output_converter,get_output_converter,remove_output_converter,clear_output_converters) for registering and managing output converter functions for specific SQL types. These converters are called when values of the registered SQL type are read from the database. (mssql_python/connection.py)Rowclass to apply registered output converters automatically to values fetched from the database, with fallback logic for string types and robust error handling. (mssql_python/row.py)Testing and validation:
NULLvalues and using multiple converters at once. (tests/test_003_connection.py)DATETIMEOFFSETand custom string handling) to support and validate the new converter system in tests. (tests/test_003_connection.py)Test and utility enhancements:
struct,datetime,timezone, and constants) to support new test cases and converter logic. (tests/test_003_connection.py)